﻿<ng-include src="'./includes/header.html'"></ng-include>

<div class="main">
    <div class="container">
      <div class="row">
      		<div class="widget stacked">	
				<div class="widget-header">
					<i class="icon-bookmark"></i>
					<h3>{{ 'SHORTCUTS' | i18n }}</h3>
				</div> <!-- /widget-header -->
				<div class="widget-content">
					<div class="shortcuts">
                        <a ng-click="vm.load()" class="shortcut">
                            <i class="shortcut-icon icon-refresh"></i>
                            <span class="shortcut-label">{{ 'REFRESH' | i18n }}</span>
                        </a>
					</div> <!-- /shortcuts -->	
				</div> <!-- /widget-content -->
			</div> <!-- /widget -->
		</div>
		<div class="row">
      		<div class="widget stacked widget-table action-table">
					
				<div class="widget-header">
					<i class="icon-th-list"></i>
					<h3>{{ 'ACTIONS' | i18n }}</h3>
				</div> <!-- /widget-header -->
				<div class="widget-content">
					<form class="form-inline">
						<label class="col-sm-3 control-label">{{ 'FILTERUSERS' | i18n }}</label>
						<div class="form-group">
                            <input type="text" id="filter_user_login" class="input-medium" placeholder="{{ 'LOGIN' | i18n }}" ng-model="filter">
						</div>
					</form>
					<table class="table table-striped table-bordered">
						<thead>
							<tr>
								 <th>#</th>
								<th>{{ 'LOGIN' | i18n }}</th>
								<th>{{ 'ROLE' | i18n }}</th>
								<th>{{ 'ACTIVE' | i18n }}</th>
                                <th>{{ 'LANGUAGE' | i18n }}</th>
								<th>{{ 'LASTIP' | i18n }}</th>
								<th>{{ 'LASTCONNECTION' | i18n }}</th>
								<th>{{ 'ACTIONS' | i18n }}</th>
							</tr>
						</thead>
						<tbody>
							 <tr ng-repeat="user in users" ng-class="{warning:user.role == 8, success : user.role == 4, danger:!user.is_active || user.is_blocked}" ng-show="filter == null || filter.length <= 0 || user.login.toLowerCase().indexOf(filter.toLowerCase()) >= 0">
								<td><span ng-bind="user.user_id"></span></td>
								<td><span ng-bind="user.login"></span></td>
								<td>
                                    <a ng-class="{'shortcut':true, 'btn':true, 'btn-primary':(user.role > 1), 'btn-default':(user.role <= 1), 'disabled':(user.role <= 1)}" role="button" ng-click=" vm.decreaseRole(user.user_id)"><span class="glyphicon glyphicon-minus"></span></a>
									<span ng-bind="user.role"></span>
                                    <a ng-class="{'shortcut':true, 'btn':true, 'btn-primary':(user.role < 8), 'btn-default':(user.role >= 8), 'disabled':(user.role >= 8)}" role="button" ng-click=" vm.increaseRole(user.user_id)"><span class="glyphicon glyphicon-plus"></span></a>
								</td>
								<td><span ng-bind="user.is_active"></span></td>
                                <td><span ng-bind="user.lang"></span></td>
								<td><span ng-bind="user.last_ip"></span></td>
								<td><span ng-bind="user.last_connection"></span></td>
								<td>
									<a class="shortcut btn btn-warning" ng-click="vm.disableUser(user.user_id)" ng-show="user.is_active && !user.is_blocked"><span class="glyphicon glyphicon-minus-sign glyphicon-white"></span></a>
                                    <a class="shortcut btn btn-success" ng-click="vm.enableUser(user.user_id)" ng-show="!user.is_active || user.is_blocked"><span class="glyphicon glyphicon-ok-circle glyphicon-white"></span></a>
                                    <a class="shortcut btn btn-info" ng-click="vm.resetPassword(user.user_id)"><span class="glyphicon glyphicon-lock glyphicon-white"></span></a>
								</td>
							</tr>
						</tbody>
					</table>
					 <div>
						<form class="form-inline" role="form" ng-show="user.role >= 8">
							<label class="col-sm-3 control-label">{{ 'NEWUSER' | i18n }}</label>
							<div class="form-group">
                                <input type="text" id="new_user_login" class="input-medium" placeholder="{{ 'LOGIN' | i18n }}" ng-model="selecteduser.login">
                                <input type="text" id="new_user_lang" class="input-medium" placeholder="{{ 'LANGUAGE' | i18n }}" ng-model="selecteduser.lang">
							</div>
							<div class="form-group">
								<button type="button" ng-click="vm.addUser(selecteduser)" ng-show="selecteduser.login && selecteduser.login.length > 0" class="btn btn-xs"><span class="glyphicon glyphicon-floppy-save"></span> {{ 'ADDUSER' | i18n }}</button>
							</div>
						</form>
					</div>
				</div> <!-- /widget-content -->
			</div>
		</div>
	</div>
</div>
